home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1995 October
/
EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso
/
Aminet
/
util
/
gnu
/
gawk_2_15_5.lha
/
gawk-2.15.5
/
awk.ych
< prev
next >
Wrap
Text File
|
1995-01-20
|
2KB
|
122 lines
Changes for AWK.Y by Andreas Scherer, January 20, 1995.
@x l.31
#include "awk.h"
@y
#include "ansiawk.h"
@z
@x l.33
static void yyerror (); /* va_alist */
@y
static void yyerror (char *,...);
@z
@x l.848
yyerror(va_alist)
va_dcl
{
va_list args;
const char *mesg = NULL;
register char *bp, *cp;
char *scan;
char buf[120];
static char end_of_file_line[] = "(END OF FILE)";
errcount++;
/* Find the current line in the input file */
if (lexptr && lexeme) {
if (!thisline) {
cp = lexeme;
if (*cp == '\n') {
cp--;
mesg = "unexpected newline";
}
for ( ; cp != lexptr_begin && *cp != '\n'; --cp)
continue;
if (*cp == '\n')
cp++;
thisline = cp;
}
/* NL isn't guaranteed */
bp = lexeme;
while (bp < lexend && *bp && *bp != '\n')
bp++;
} else {
thisline = end_of_file_line;
bp = thisline + strlen(thisline);
}
msg("%.*s", (int) (bp - thisline), thisline);
bp = buf;
cp = buf + sizeof(buf) - 24; /* 24 more than longest msg. input */
if (lexptr) {
scan = thisline;
while (bp < cp && scan < lexeme)
if (*scan++ == '\t')
*bp++ = '\t';
else
*bp++ = ' ';
*bp++ = '^';
*bp++ = ' ';
}
va_start(args);
if (mesg == NULL)
mesg = va_arg(args, char *);
strcpy(bp, mesg);
err("", buf, args);
va_end(args);
exit(2);
}
@y
yyerror(char *mesg,...)
{
va_list args;
register char *bp, *cp;
char *scan;
char buf[120];
static char end_of_file_line[] = "(END OF FILE)";
errcount++;
/* Find the current line in the input file */
if (lexptr && lexeme) {
if (!thisline) {
cp = lexeme;
if (*cp == '\n') {
cp--;
mesg = "unexpected newline";
}
for ( ; cp != lexptr_begin && *cp != '\n'; --cp)
continue;
if (*cp == '\n')
cp++;
thisline = cp;
}
/* NL isn't guaranteed */
bp = lexeme;
while (bp < lexend && *bp && *bp != '\n')
bp++;
} else {
thisline = end_of_file_line;
bp = thisline + strlen(thisline);
}
msg("%.*s", (int) (bp - thisline), thisline);
bp = buf;
cp = buf + sizeof(buf) - 24; /* 24 more than longest msg. input */
if (lexptr) {
scan = thisline;
while (bp < cp && scan < lexeme)
if (*scan++ == '\t')
*bp++ = '\t';
else
*bp++ = ' ';
*bp++ = '^';
*bp++ = ' ';
}
va_start(args,mesg);
strcpy(bp, mesg);
err("", buf, args);
va_end(args);
exit(2);
}
@z